<extend name="Public/base"/>

<block name="body">
	 <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<div class="main-title"> <h2>{$meta_title}</h2> </div> 
	<div class="data-table">
		<form action="{:U('saveFeature')}" class="form-horizontal config-form">
			<fieldset>

				<empty name="featureItems">
	                    <div class="alert alert-block">
						    <button type="button" class="close" data-dismiss="alert">&times;</button>
						    <h4>注意！您还没有设置特色内容导航的图标设置</h4>
						    您的站点还没有设置特色内容导航，在站点的首页里将不会有图标导航的模块，您可以在下面的栏目中进行配置，记得点确定保存哦。
						 </div>
				</empty>
					 		<form action="{:U('saveFeature')}" method="post" accept-charset="utf-8">
					 			
					 			<div class="control-group">
									<label class="control-label" for="inputTitle">特色区标题:</label>
									<div class="controls">
									<input type="text" id="inputTitle" name="title" class="span4" placeholder="为您的特色展示区取一个标题" value="{$featureTitle}">
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="inputMoreLinkUrl">更多链接的指向：</label>
									<div class="controls">
									<input type="text" id="inputMoreLinkUrl" name="moreLinkUrl" class="span4" placeholder="当用户点击更多链接时的指向地址" value="{$featureMoreLinkUrl}">
									</div>
								</div>
					 			<hr />
								<div class="feature-items">
                                    <for start="1" end="5">
                                            <div class="container-fluid">
                                                <div class="row">
                                                    <h3>特色内容.{$i}</h3>
                                                </div>
                                                <div class="row">
                                                    <div class="input-prepend span6">
                                                        <div class="row">
                                                        <span class="add-on span2">选择类型</span>
                                                        <select name="items[{$i}][type]" class="span4" id="segment{$i}">
                                                            <option value="diy" <eq name="featureItems[$i]['type']" value="diy">selected="true"</eq>>自定义</option>
                                                            <option value="category" <eq name="featureItems[$i]['type']" value="category">selected="true"</eq>>分类</option>
                                                            <option value="article" <eq name="featureItems[$i]['type']" value="article">selected="true"</eq>>文章</option></select>
                                                        </div>
                                                        <div class="row">
                                                        <span class="span2 add-on">填写编号</span>
                                                        <input id="item{$i}id" class="span4" name="items[{$i}][id]" type="text" value="{$featureItems[$i]['id']}">
                                                        </div>
                                                        <div class="row">
                                                        <span class="span2 add-on">填写标题</span>
                                                        <input id="item{$i}title" class="span4" name="items[{$i}][title]" type="text" value="{$featureItems[$i]['title']}">
                                                        </div>
                                                        <div class="row">
                                                        <span class="span2 add-on">填写简介</span>
                                                            <textarea id="item{$i}description" class="span4" name="items[{$i}][description]" rows="4">{$featureItems[$i]['description']}</textarea>
                                                        </div>
                                                        <div class="row">
                                                        <span class="span2 add-on">填写链接地址</span>
                                                        <input id="item{$i}url" class="span4" name="items[{$i}][url]" type="text" value="{$featureItems[$i]['url']}">
                                                        </div>
                                                    </div>
                                                    <div class="controls span6">
                                                        <input type="file" id="upload_picture_{$i}">
                                                        <input type="hidden" name="items[{$i}][cover_id]" id="cover_id_{$i}" value="{$featureItems[$i]['cover_id']}"/>
                                                        <div class="upload-img-box">
                                                                <div class="upload-pre-item"><img src="{$featureItems[$i]['cover']}" alt="{$featureItems[$i]['alt']}"/></div>
                                                        </div>
                                                    </div>
                                                    <script type="text/javascript">
                                                        //上传图片
                                                        /* 初始化上传插件 */
                                                        $("#upload_picture_{$i}").uploadify({
                                                            "height"          : 30,
                                                            "swf"             : "__STATIC__/uploadify/uploadify.swf",
                                                            "fileObjName"     : "download",
                                                            "buttonText"      : "上传图片",
                                                            "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                                                            "width"           : 120,
                                                            'removeTimeout'    : 1,
                                                            'fileTypeExts'    : '*.jpg; *.png; *.gif;',
                                                            "onUploadSuccess" : uploadPicture{$i},
                                                        'onFallback' : function() {
                                                            alert('未检测到兼容版本的Flash.');
                                                        }
                                                        });
                                                        function uploadPicture{$i}(file, data){
                                                            var data = $.parseJSON(data);
                                                            var src = '';
                                                            if(data.status){
                                                                $("#cover_id_{$i}").val(data.id);
                                                                src = data.url || '__ROOT__' + data.path
                                                                $("#cover_id_{$i}").parent().find('.upload-img-box').html(
                                                                        '<div class="upload-pre-item"><img src="__ROOT__' + src + '"/></div>'
                                                                );
                                                            } else {
                                                                updateAlert(data.info);
                                                                setTimeout(function(){
                                                                    $('#top-alert').find('button').click();
                                                                    $(that).removeClass('disabled').prop('disabled',false);
                                                                },1500);
                                                            }
                                                        }
                                                    </script>
                                                </div>
                                            </div>
                                        <hr/>
                                    </for>

							 </form>
			</fieldset>

			<button target-form="form-horizontal" type="submit" id="submit" class="btn submit-btn ajax-post hidden"><i class="icon-ok"></i> 确 定</button>
    		 <a class="btn btn-return" href=""><i class="icon-chevron-left"></i> 返 回</a>
    		 <notempty name="featureItems">
    		 <a href="{:U('clear?part=Feature')}" class="btn submit-btn confirm ajax-get"><i class="icon-warning-sign"></i>  清除所有特色内容</a>
			</notempty>
		</form>

	</div>

</block>

<block name="script">
	<include file="Public/footjs" />

	<script type="text/javascript">

		$(".button-flat-caution.slide").click(function(){
		$(this).parent("li").detach();});
		
	</script>
</block>
